#!/usr/bin/env python
# -*- coding: utf8 -*-

"""
config.py

Read configurations from /etc/pyspi.conf
THIS IS PART OF PYSPI PROJECT
DO NOT USE IT DIRECTLY
"""

import ConfigParser

class Config(object):
    """
    get configurations from /etc/pyspi.conf
    """
    def __init__(self):
        """
        read file and save configs into class variables
        """
        conf = ConfigParser.ConfigParser()
        try:
            conf.read('/etc/pyspi.conf')
            self.pages = conf.get('Spider', 'pages', 1)
            self.database = conf.get('database', 'file', 1)
            self.startpage = conf.get('Spide', 'startpage', 0)
            if conf.get('Spider', 'webautostart', 1) == 'true':
                self.webAutostart = True
        except:
            self.pages = 1000
            self.database = '/tmp/pyspi_base'
            self.startpage = 'http://www.wykop.pl/'
            self.webAutostart = False

if __name__ == "__main__":
    print "Config is a part of pyspi.\
        \nDon't use it directly."
